#ifndef	Q_EFFECT_H
#define Q_EFFECT_H
#include "stdafx.h"
#include <GLES2/gl2.h>
class CShader;
class VertexShader;
class FragmentShader;
// define the semantic effect

class CEffect
{

public:
	typedef std::map< std::string, GLint > ELEMENTMAP;
	CEffect( const char * pName );
	~CEffect(void);

	// active the effect when draw the object
	void Activate();
	
	// destroy the effect when quit the program
	void Destroy();

	// from file or buid by youself
	void Create( CShader & pVertexShader, CShader & pFragmentShader, const char ** pAttribs, const char ** pUniforms );

private:

	// Load the vertex and fragment shader from the source
	bool CompileFromMemory( const char * pSource, GLenum eType, GLuint & iHandle );

	// Create And build the program
	bool CreateAndBuildProgram( GLuint iVertex, GLuint iFragment, const char ** pAttibs, const char ** pUniforms );

	// Create the program
	bool CreateProgram( GLuint iVertex, GLuint iFragment );

	// Build the program
	bool BuildProgram( const char ** pAttribs, const char ** pUniforms );

	// LoadTextures from texture name
	bool LoadTextures( const char ** pTextures );

	
private:

	std::string		m_strName;
	GLuint			m_uiProgram;

	GLint			*m_pTextures;
	unsigned int	m_nTextureNum, m_nTextureMax;

	ELEMENTMAP		m_mapAttributs;
	ELEMENTMAP		m_mapUniforms;
};

#endif
